<template>
	<view class="setPadding">
	<u-navbar bgColor="#00aa8f" leftText="返回" titleStyle="color:#fff"  title="订单详情"
		:placeholder="true" :safeAreaInsetTop="true" :border="true">
		<view class="u-nav-slot  setDisplayCenter " slot="left">
			<view class="" @click="toUserCenter()">
				<u-icon name="home" size="40" color="#fff"></u-icon>
			</view>
		</view>
			
		<view class="" slot="right">
			<!-- #ifdef APP-PLUS  -->
			<share></share>
			<!-- #endif -->
		</view>
		
	</u-navbar>
	
		<view  class="setVerticalLayout">
			
			<view v-if="limitId" @click="toLastRead()" class="orderBox settextRight setcolor">
				当前查阅页面
				<!-- <text  class="setcolor"></text> -->
			</view>
			<view class="setVerticalLayout setPadding">
				<text class="setWeight setFont">支付成功！</text>
				<text class="setFont setPadding">￥{{order.payMoney/100}}</text>
				<view class="setFontColor1 setMarginVertical" >您已充值￥{{order.payMoney/100}}，获取会员权限{{order.days}}天</view>
			</view>
			<view class="setRadius setBgfff orderBox setPadding" style="font-size: 30rpx;">
				<view class="setVerticalCenter">
					<view class="setVerticalCenter" v-if="order.payType=='weixinPay'">
						<uni-icons type="weixin" color="#3dd014" size="20"></uni-icons>
					</view>
					<view class="setVerticalCenter" v-else>
						<uni-icons type="zhifubao" color="#3dd014" size="20"></uni-icons>
					</view>
					支付信息
				</view>
				<u-line color="#eee" />
				<view class="sethorizontalbetween  setMarginVertical">
					<text>支付金额</text>
					<text class="setWeight">￥{{order.payMoney/100}}</text>
				</view>
				
				<view v-if="order.timestamp" class="sethorizontalbetween  setMarginVertical">
					<text>交易时间</text>
					<text class="setFontColor1 setfontSize2">{{$u.timeFormat(order.timestamp,'yyyy年mm月dd日 hh时MM分ss秒')}}</text>
				</view>
				<view v-if="order.tradeNo" class="sethorizontalbetween  setMarginVertical">
					<text>订单编码</text>
					<text class="setFontColor1 setfontSize2">{{order.tradeNo}}</text>
				</view>
				
			</view>
			<view class="setPadding" style="width: 80%;margin-top: 100rpx;">
				<u-button @click="toUserCenter()" type="success">完成</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {

		data() {
			return {
				// 当前是否有未阅读页面
				limitId:null,
				// 订单详情
				order:{
					payMoney:0,
					days:0,
					payType:0	
				}
			}
		},
		onLoad(option) {
			if(option.outTradeNo){
				// 访问订单详情
				this.getfindPayLogByOrderId(option.outTradeNo)
				
			}
		},
		onShow() {
			 this.limitId=uni.getStorageSync('limitId');
			
		},
		beforeDestroy() {
			// 清除阅览缓存
			uni.removeStorageSync('limitId');
			// 用户个人信息更新
			uni.$emit('bindVip')
		},
		methods:{
			// 跳转至上次阅读页面
			toLastRead(){
				
				if(this.limitId.type=='zhaobiao'){
					// 招标详情
					uni.reLaunch({
						url: '/pagesIndex/detail?id=' + this.limitId.id
					});
				}else{
					// 企业详情
					uni.reLaunch({
						url: '/pagesFind/detailenterprise/detailenterprise?companyCid=' + this.limitId.id
					});
				}
			
			},
			
			getfindPayLogByOrderId(id){		
				this.$app.request({
					url: this.$baseApp.api.pay.findPayLogByOrderId,
					method: 'POST',
					data:{
						outTradeNo:id
					},
					dataType: 'json',
					success: res => {
						
						if(res.data){
							this.order=res.data[0]
							
						}	
					},
					complete: res => {
					
					}
				});
			},
			// 跳转至个人中心页面
			toUserCenter(){
				
				uni.switchTab({
					url: '/pages/user/index'
				});
			},
			leftClick() {
			
				uni.switchTab({
					url: `/pages/index/index`
				})
			}
		}
	}
</script>

<style>
	.orderBox{
		width: 100%;
	}
</style>
